package com.example.briandang;

import android.support.v7.app.ActionBarActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

/*
 * When creating this SecondActivity, go to
 * 		New ==> Android Activity
 * The "Hierarchical Parent" is used to specify the parent Activity
 * that the UI navigates to when *this* activity presses the UP button
 * */

public class DisplayMessageActivity extends ActionBarActivity 
{
	/* This method is called when this activity is started 
	 * All sublcasses of Activity must implement the onCreate() method
	 * System calls this when creating a new instance of the activity
	 * 
	 * EVERY activity is invoked by an Intent, regardless of how
	 * the user navigated there.
	 * 
	 * You can get the Intent that started the activity by calling
	 * getIntent() and retrieve the data contained within it
	 * */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		
		// Get the Intent
		Intent intent = getIntent();
		String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
		
		// Display the message
		// To show the message on screen, create a TextView widget and
		// set the text using setText(). Then add TextView as the root view
		// of the activity's layout by passing it to setContentView()
		TextView textView = new TextView(this);
		textView.setTextSize(40);
		textView.setText(message);
		
		//setContentView(R.layout.activity_display_message);
		
		// Set text view as the activity layout
		setContentView(textView);
		
		//  To enable the UP functionality for this activity to go to its' parent activity
		getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.display_message, menu);
		return true;
	}

	/* Handles the behavior for the action bar's Up behavior */
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
